<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jstl/core">

	<h:head>
		<title>Sitema de Pedidos Mary Jane - Autenticação</title>
	</h:head>
	
	<ui:composition template="/templates/fabio.xhtml">
		
		<ui:define name="titulo">
			Sistema de Pedidos Mary Jane
		</ui:define>
		
		<ui:define name="corpo">
        
            <h:panelGroup rendered="#{!empty param.login_error}">
				Erro ao efetuar o login.
				<br/> Motivo: #{SPRING_SECURITY_LAST_EXCEPTION.message} <br/>
			</h:panelGroup>
            
            <hr/>
            
            <p:panelGrid columns="2">  
    			<f:facet name="header">  
        			Autenticação  
			    </f:facet>    
            	<h:form id="login" prependId="false">
	        		<h:messages id="messages" for="login" showDetail="true" autoUpdate="true" closable="true" />  
	        		<p:panelGrid columns="2">
	            		<p:outputLabel for="j_username" value="Usuário: " />
		            	<p:inputText id="j_username" size="15" required="true"/>
		            	<p:outputLabel for="j_password" value="Senha: " />
		            	<p:password id="j_password" size="15" required="true"/>
		            	<h:outputText value="Entrar Automaticamente: " />  
		            	<p:selectBooleanCheckbox name="_spring_security_remember_me" />
	            	</p:panelGrid>
            		<p:commandButton value="Entrar" ajax="false" icon="ui-icon-check" style="margin:0"
	            					 onclick="document.login.action='#{request.contextPath}/j_spring_security_check';document.login.method='post';" />
	        		<script>
						document.getElementById("login").j_username.value = "#{SPRING_SECURITY_LAST_USERNAME}";
					</script>
	        	</h:form>
	        </p:panelGrid>
	        
		</ui:define>
	</ui:composition>	
</html>
